﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.IO;
using System.Runtime.Serialization;
using System.Net;
using System.Net.Http;
using System.ServiceModel;
using System.ServiceModel.Syndication;
using System.Text;
using System.Web.Http;
using System.Xml;

namespace LynxWikiSyndication.Controllers
{
    [KnownType(typeof(Rss20FeedFormatter))]
    public class RssFeedController : ApiController
    {
        // GET api/values
        public HttpResponseMessage GetRss(HttpRequestMessage hReqMsg)
        {
            SyndicationFeed feed = new SyndicationFeed("LynxWiki Feed", "A LynxWiki Syndication Feed v1.3.1.6", new Uri(ConfigurationManager.AppSettings["WebSiteUrl"]));
            feed.Copyright = new TextSyndicationContent(ConfigurationManager.AppSettings["CopyRight"]);
            feed.ImageUrl = new Uri(ConfigurationManager.AppSettings["FeedImage"]);

            List<SyndicationItem> items = GetFeedItems.GetSyndicationTopics();
            feed.Items = items;

            SyndicationFeedFormatter formatter = new Rss20FeedFormatter(feed);

            return GetFeedItems.GetResponse(formatter);
        }
    }
}